const { ModuleFederationPlugin } = require('webpack').container

module.exports = {
  publicPath: process.env.NODE_ENV === 'production'
    ? 'https://host.example.com/'
    : 'http://localhost:8080/',
  devServer: {
    port: 8080,
    historyApiFallback: true
  },
  configureWebpack: {
    plugins: [
      new ModuleFederationPlugin({
        name: 'hostApp',
        filename: 'remoteEntry.js',
        remotes: {
          userApp: 'userApp@http://localhost:8081/remoteEntry.js',
          orderApp: 'orderApp@http://localhost:8082/remoteEntry.js'
        },
        shared: {
          vue: {
            singleton: true,
            requiredVersion: require('./package.json').dependencies.vue
          },
          'vue-router': {
            singleton: true,
            requiredVersion: require('./package.json').dependencies['vue-router']
          }
        }
      })
    ]
  },
  // 启用Vue运行时编译
  runtimeCompiler: true
}
